package MULE.Model;

import java.util.ArrayList;
import java.util.EnumSet;

/**
 * An enumeration of player races.
 */
public enum Race {

	HUMAN(1200), ELF(1000), GOBLIN(1400), DWARF(800);

	private int startingMoney;

	private Race(int startingMoney) {
		this.startingMoney = startingMoney;
	}

	public int getStartingMoney() {
		return this.startingMoney;
	}

	/**
	 * Returns a list containing all Player Race names as strings.
	 * 
	 * @return String array containing player race names.
	 */
	public static String[] getRaceNames() {
		// Generate array of Player.Race names.
		ArrayList<String> raceNames = new ArrayList<String>();
		for (Race race : EnumSet.allOf(Race.class)) {
			raceNames.add(race.toString());
		}
		return raceNames.toArray(new String[raceNames.size()]);
	}

	/**
	 * Returns the Race type corresponding to the given string.
	 * 
	 * @param raceName
	 *            Name of race as string.
	 * @return Race type that matches given string.
	 */
	public static Race getRace(String raceName) {
		// Look for race name in list.
		for (Race race : EnumSet.allOf(Race.class)) {
			if (race.toString().equals(raceName)) {
				return race;
			}
		}
		return null;
	}
}